<!DOCTYPE html>
<html lang="zh-cn">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title>网站信息</title>
  <link rel="stylesheet" href="../../css/pintuer.css">
  <link rel="stylesheet" href="../../css/admin.css">
  <script src="../../js/jquery.js"></script>
  <script src="../../js/pintuer.js"></script>
  <script src="../../js/jquery.form.js"></script>
</head>
<style>
html {
overflow-x: hidden;
overflow-y: auto;
}
</style>
<body>
  <div class="panel admin-panel">
    <div id="info"></div>
    <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>添加用户</strong></div>
    <div class="body-content">
      <form class="form-x" id="assetForm" enctype="multipart/form-data">
        <div class="form-group">
          <div class="label">
            <label>用户名：</label>
          </div>
          <div class="field">
            <input type="text" id="url1" name="username" class="input tips" style="width:25%; float:left;" value="" />
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>密码：</label>
          </div>
          <div class="field">
            <input type="text" id="url2" name="pwd" class="input tips" style="width:25%; float:left;" value="" />
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>卡号：</label>
          </div>
          <div class="field">
            <input type="text" id="url3" maxlength="4" name="idcard" class="input tips" style="width:25%; float:left;" value="" placeholder="卡号为4位数字"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label for="income">
              余额：</label>
          </div>
          <div class="field">
            <div class="input-group">
              <span class="addon">￥</span>
              <input class="input" type="text" id="money" maxlength="5" name="balance" size="50" placeholder="不能超过5位数金额" /><span
                class="addon">元</span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>VIP 会员：</label>
          </div>
          <!-- <div class="field">
            <input type="radio" value="1" name="ismember">会员
            <input type="radio" value="0" name="ismember">非会员
          </div> -->
          <div class="button-group radio">
            <label class="button">
              <input value="1" name="ismember" type="radio"><span class="icon icon-check"></span> 是
            </label>
            <label class="button">
              <input value="0" name="ismember" type="radio"><span class="icon icon-times"></span> 否
            </label>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label></label>
          </div>
          <div class="field" style="margin-top: 20px">
            <button class="button bg-main icon-check-square-o" type="button" id="agreementSub"> 提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</body>
<script>
  $(document).ready(function () {
    $('#agreementSub').on('click', function () {
      $('#assetForm').ajaxSubmit({
        url: 'http://127.0.0.1:3000/api/user/adduser',
        type: 'get',
        dataType: 'jsonp',
        data: $('#assetForm').serialize(),
        success: function (data) {
          console.log(data)
          if (data.code == 1) {
            window.location.href = "user.html?info='操作成功'"
          } else if(data.code == 0){
            var str =
              `
                    <div class="alert alert-red">
                      <span class="close rotate-hover"></span><strong>注意：</strong>${data.msg}</div>
                    </div>
                `
            $('#info').html(str)
            setTimeout(function () {
              $('#info').html('')
            }, 2000)
          }else{
          }
        },
        error: function (err) {
          console.log(err)
        },
        clearForm: false, //禁止清除表单
        resetForm: false //禁止重置表单
      })
    })
  })
</script>

</html>